<?php

class PageApi extends ApiBase
{
	private $mysql = null;

	public function __construct()
	{
		parent::__construct();
		$this->mysql = n_api('mysql')->cname('weixin');
	}

	public function getPageInfoById($id)
	{
		$query = "select * from page_main where id = $id and isdel = 'N'";
		$rs = $this->mysql->fetchFirst($query);

		return $rs;
	}

	public function getAllSlides()
	{
		$rs = $this->mysql->select("select * from page_slide where isdel = 'N'");
		foreach ($rs as $value) {
			$value['imgPath'] = '/page/slide/' . $value['img_name'];
			$data[] = $value;
		}
		return $data;
	}

	public function getSlideById($id) {
		$rs = $this->mysql->fetchFirst("select * from page_slide where id = $id and isdel = 'N'");
		$rs['imgPath'] = '/page/slide/' . $rs['img_name'];
		return $rs;
	}
}